//
//  HomePageNoteWriteViewController.m
//  product_B
//
//  Created by lanou on 16/5/29.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "HomePageNoteWriteViewController.h"

@interface HomePageNoteWriteViewController ()<UITextViewDelegate>
@property (nonatomic,strong)UITextView *contentTV;
@end

@implementation HomePageNoteWriteViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = [UIColor whiteColor];
    self.titleLabel.text = @"";
    self.searchButton.frame = CGRectMake(20, 30, 50, 20);
    [self.searchButton setTitle:@"取消" forState:UIControlStateNormal];
    [self.searchButton setTintColor:[UIColor grayColor]];
    [self.searchButton setBackgroundImage:nil forState:UIControlStateNormal];
    self.userButton.frame = CGRectMake(kWidth - 65, 30, 50, 20);
    [self.userButton setTitle:@"确定" forState:UIControlStateNormal];
    [self.userButton setTintColor:[UIColor grayColor]];
    [self.userButton setBackgroundImage:nil forState:UIControlStateNormal];
    
    self.contentTV = [[UITextView alloc]initWithFrame:CGRectMake(0, 64, kWidth, kHeight-64)];
    self.contentTV.text = self.contentString;
    self.contentTV.font = [UIFont systemFontOfSize:17];
    self.contentTV.delegate = self;
   
    [self.view addSubview:_contentTV];
}

- (void)searchButtonAction:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)userButtonAction:(UIButton *)sender{
    if ([self.delegate respondsToSelector:@selector(changeContent:)]){
        [self.delegate changeContent:_contentTV.text];
    }
    [self.navigationController popViewControllerAnimated:YES];
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
//    [textView resignFirstResponder];
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
    return YES;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [_contentTV resignFirstResponder];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
}
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
